#include<iostream>
#include<string>
using namespace std;
int k[105];
int main()
{
int n,m;
cin>>n>>m;
string a="alloc";
string b="erase";
string c="defragment";
for(int i=m;i<105;i++)
{
k[i]=9999999;
}
int cnt2=1;
for(int i=0;i<n;i++)
{
string d;
int temp;
cin>>d;
if(d!=c)
cin>>temp;
if(d==a)
{
//cout<<"XXXX"<<endl;
//cnt2++;
int cnt=0;
int mark=999999999;
for(int i=0;i<m;i++)
{
if(k[i]==0)
{
cnt++;
}
else
{
cnt=0;
}
if(cnt>=temp)
{
mark=i;
break;
}
}
if(mark!=999999999)
{
for(int i=0;i<temp;i++)
{
k[mark-i]=cnt2;
}
cout<<cnt2<<endl;
cnt2++;
}
else
{
cout<<"NULL"<<endl;
}
}
if(d==b)
{
int cnt=0;
int mark=999999988;
for(int i=0;i<m;i++)
{
if(k[i]==temp)
{
mark=i;
break;
}
}
if(mark!=999999988&&temp!=0)
{
for(int i=mark;k[i]==temp;i++)
{
k[i]=0;
}
}
else
{
cout<<"ILLEGAL_ERASE_ARGUMENT"<<endl;
}
}
if(d==c)
{
while(1)
{
int mark1=9999998,mark2=9999998,mark3=9999998;
for(int i=0;i<m;i++)
{
if(k[i]==0)
{
mark1=i;
break;
}
}
for(int i=mark1;i<m;i++)
{
if(k[i]!=0)
{
mark2=i;
break;
}
}
if(mark2!=9999998)
{
for(int i=mark2;k[i]==k[mark2];i++)
{
mark3=i;
}
int m=k[mark2];
for(int i=mark2;i<=mark3;i++)
{
k[i]=0;
}
for(int i=mark1;i<mark1+mark3-mark2+1;i++)
{
k[i]=m;
}
}
else
{
break;
}
}
}
}
}
25A - IQ test | 785A - Anton and Polyhedrons |
1542B - Plus and Multiply | 306A - Candies |
1651C - Fault-tolerant Network | 870A - Search for Pretty Integers |
1174A - Ehab Fails to Be Thanos | 1169A - Circle Metro |
780C - Andryusha and Colored Balloons | 1153A - Serval and Bus |
1487C - Minimum Ties | 1136A - Nastya Is Reading a Book |
1353B - Two Arrays And Swaps | 1490E - Accidental Victory |
1335A - Candies and Two Sisters | 96B - Lucky Numbers (easy) |
1151B - Dima and a Bad XOR | 1435B - A New Technique |
1633A - Div 7 | 268A - Games |
1062B - Math | 1294C - Product of Three Numbers |
749A - Bachgold Problem | 1486B - Eastern Exhibition |
1363A - Odd Selection | 131B - Opposites Attract |
490C - Hacking Cypher | 158B - Taxi |
41C - Email address | 1373D - Maximum Sum on Even Positions |